package com.yomahub.liteflow.example.xstream;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import com.thoughtworks.xstream.converters.basic.BooleanConverter;
import com.thoughtworks.xstream.converters.extended.ToAttributedValueConverter;
import com.yomahub.liteflow.example.xstream.converter.SingleValueCalendarConverter;

import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;

/**
 * 别名注解和隐式集合注解
 **/
@XStreamAlias("message")
public class RendezvousMessage {
    @XStreamAsAttribute
    @XStreamAlias("type")
    private int messageType;


    @XStreamImplicit(itemFieldName="part")
    private List<String> content;

    //    private List<String> content;
    @XStreamAsAttribute
    @XStreamConverter(value= BooleanConverter.class, booleans={false}, strings={"yes", "no"})
    private boolean important;


    @XStreamConverter(SingleValueCalendarConverter.class)
    private Calendar created = new GregorianCalendar();

    private String name;

    public RendezvousMessage(int messageType, boolean important, String ...args) {
        this.messageType = messageType;
//        this.content = ListUtil.toList(args);
        this.content = Arrays.asList(args);
        this.important = important;
        this.name = "zjy";
    }

}
